from time import *
file1 = open("m1_sorted.txt").readlines()
file2 = open("m2_reverse.txt").readlines()
file3 = open("m3_shuffle.txt").readlines()


n = 5000
for i in range(n):
    file1[i]=int(file1[i])
time1_1 = time()
for i in range(n-1):
    k = 0
    for j in range(n-i-1):
        if file1[j] > file1[j+1]:
            file1[j], file1 [j+1] = file1[j+1], file1[j]
            k += 1
    if k == 0:
        break
time1_2 = time()
total1 = (time1_2 - time1_1)*1000
total1 = round(total1)
print(total1)


for i in range(n):
    file2[i]=int(file1[i])
time1_1 = time()
for i in range(n-1):
    k = 0
    for j in range(n-i-2):
        if file2[j] > file2[j+1]:
            file2[j], file2 [j+1] = file2[j+1], file2[j]
            k += 1
    if k == 0:
        break
time1_2 = time()
total1 = (time1_2 - time1_1)*1000
total1 = round(total1)
print(total1)


for i in range(n):
    file3[i]=int(file3[i])
time1_1 = time()
for i in range(n-1):
    k = 0
    for j in range(n-i-1):
        if file1[j] > file1[j+1]:
            file1[j], file1 [j+1] = file1[j+1], file1[j]
            k += 1
    if k == 0:
        break
time1_2 = time()
total1 = (time1_2 - time1_1)*1000
total1 = round(total1)
print(total1)


for i in range(n):
    file3[i]=int(file3[i])
time1_1 = time()
for i in range(n-1):
    k = 0
    for j in range(n-i-3):
        if file3[j] > file3[j+3]:
            file3[j], file3 [j+1] = file3[j+1], file3[j]
            k += 1
    if k == 0:
        break
time1_2 = time()
total1 = (time1_2 - time1_1)*1000
total1 = round(total1)
print(total1)






            
